<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.js"></script>
    <script>
        // 添加两个请求拦截器（回调函数）
        axios.interceptors.request.use(
            config => {
                console.log('request interceptor1 onResolved()')//2
                return config
            }
        )

        axios.interceptors.request.use(
            config => {
                console.log('request interceptor2 onResolved()')//1
                return config
            }
        )

        axios.interceptors.response.use(
            response => {
                console.log('response interceptor1 onResolved()')
                return response
            },
            error => {
                console.log('response interceptor1 onResolved()')
                return Promise.reject(error)
            }
        )

        axios.interceptors.response.use(
            response => {
                console.log('response interceptor2 onResolved()')
                return response
            },
            error => {
                console.log('response interceptor2 onResolved()')
                return Promise.reject(error)
            }
        )




        axios.get('http://localhost:3000/posts')
            .then(response => {
                console.log('data', response.data)
            }, error => {
                console.log('error', error.message)
            })



    </script>
</body>

</html>